<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let graph = {
            '0': ['a', 'b', 'c'],
            '1': ['d', 'e', 'f'],
            '2': ['g', 'h', 'i'],
            '3': ['j', 'k', 'l'],
            '4': ['m', 'n', 'o'],
            '5': ['p', 'q', 'r'],
            '6': ['s', 't'],
            '7': ['u', 'v'],
            '8': ['w', 'x'],
            '9': ['y', 'z'],
        }

        let input = `0123456
        adgjmp`
        let [index, no] = input.split('\n').map(v => v.trim())
        let res = []
        function dps(i, now, graph) {
            let tem =graph[ index[i]];       
            for (const item of tem) {               
                if (i < index.length-1) {
                    dps(i + 1, now + item, graph)
                }else{
                    const str =now+item
                    let tag=0
                    for(let char of no){
                        if(str.includes(char)){
                            tag++
                        }
                    }
                    if(tag!==no.length){
                        res.push(str) 
                    }
                    
              
                }
            }

        }
        dps(0, '', graph)





        console.log(res);

        let str='abcdef'
        console.log();
        





    </script>
</body>

</html>